<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    var arr = [2, 45, 23, 45];
    // var a,b,c,d;
    // 基本
    var [a, b, c, d] = [2, 45, 23, 45];
    console.log(a, b, c, d);
    //可忽略
    var [a, , c, d] = [2, 45, 23, 45];
    console.log(a, c, d);

    //剩余运算符结构
    var [a, ...b] = [12, 43, 23, 5, 65, 45]
    console.log(a, b);
    // 默认值
    var [a = 1, b, c = 3] = []
    console.log(a, b, c);
    var [a = 1, b = a] = [2, 4]
    console.log(a, b);

    //字符串结构
    var [a, b, c, d] = "admin"
    console.log(a, b, c, d);

    // 嵌套
    var [a, b, [c, d]] = [2, 45, [23, 45]];
    console.log(a, b, c, d);
  </script>
</body>

</html>